﻿
using SqlSugar.Extensions;

namespace TestPressure
{
    public partial class SystemSetForm : BaseForm
    {
        #region 系统方法
        public SystemSetForm()
        {
            InitializeComponent();
            Header.Text = "系统设置";
        }


        private void SystemSetForm_Load(object sender, EventArgs e)
        {
            Log.Debug(Config.BroadcastTestData.ToString());

            BroadcastDataCheckbox.Checked = Config.BroadcastTestData;
            DataTimeInput.Text = Config.BroadcastTestDataTimeInterval.ToString();

            BroadcastRemoteErrorCheckbox.Checked = Config.BroadcastRemoteError;
            BroadcastRemoteErrorTimeInput.Text = Config.BroadcastRemoteErrorTimeInterval.ToString();

            BroadcastPressureIntervalCheckbox.Checked = Config.BroadcastPressureInterval;
            PressureIntervalRangeInput.Text = Config.PressureIntervalRange.ToString();
            BroadcastPressureIntervalTimeInput.Text = Config.PressureIntervalTime.ToString();
            BroadcastStartCheckbox.Checked = Config.BroadcastStart;
        }

        #endregion

        #region 响应事件
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            Config.BroadcastTestData = BroadcastDataCheckbox.Checked;

            Config.BroadcastTestDataTimeInterval = DataTimeInput.Text.ObjToInt();

            Config.BroadcastRemoteError = BroadcastRemoteErrorCheckbox.Checked;
            Config.BroadcastRemoteErrorTimeInterval = BroadcastRemoteErrorTimeInput.Text.ObjToInt();

            Config.BroadcastPressureInterval = BroadcastPressureIntervalCheckbox.Checked;
            Config.PressureIntervalRange = PressureIntervalRangeInput.Text.ObjToInt();
            Config.PressureIntervalTime = BroadcastPressureIntervalTimeInput.Text.ObjToInt();
            Config.BroadcastStart = BroadcastStartCheckbox.Checked;
            this.Close();
        }
        #endregion
    }
}
